package com.own.business.exam.common.handler;

import com.own.business.exam.common.exception.ExamException;
import com.own.component.common.model.ExceptionMessageModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ExamExceptionHandler
 *
 * @author chenxueli
 * @date 2021-6-17 16:37:10
 */
@Slf4j
@Order(1)
@RestControllerAdvice
public class ExamExceptionHandler {

    /**
     * 处理 ExamException 异常
     *
     * @param e 异常信息
     * @return 返回信息
     */
    @ExceptionHandler(ExamException.class)
    public ExceptionMessageModel handleException(ExamException e) {
        log.error(e.getMessage(), e);
        return new ExceptionMessageModel(e);
    }

}
